package servlet;

import pojo.Admin;
import pojo.Menu;
import pojo.Role;
import service.AdminService;
import service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 登录成功后回显的servlet
 */
@WebServlet(value = "/BgLoginEchoServlet")
public class BgLoginEchoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Object id=request.getSession().getAttribute("session");
        AdminService as=new AdminServiceImpl();
        Admin admin=as.queryAdmin((int)id);
        Role role=as.queryOneRole((int)id);
        List<Menu> menus=as.roolMenu((int)id);
        request.setAttribute("admin",admin);
        request.setAttribute("role",role);
        request.setAttribute("menus",menus);
        request.getRequestDispatcher("jsp/yjj/DisplayMenu.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doPost(request,response);
    }
}
